package com.example.aimnear;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class FullscreenActivity extends Activity
{
	private ListView tasksListView;
	private Button addTaskButton;
	private EditText taskNameText;
	private ArrayList<String> values = new ArrayList<String>();
	private ArrayAdapter<String> adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_fullscreen);
		taskNameText = (EditText)findViewById(R.id.editText1);
		setList();
		setButton();
	}

	protected void setList()
	{
		tasksListView = (ListView) findViewById(R.id.listView1);
		adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values);
		tasksListView.setAdapter(adapter);
	}

	protected void setButton()
	{
		addTaskButton = (Button)findViewById(R.id.button1);
		addTaskButton.setOnClickListener(
				new OnClickListener() {
					@Override
					public void onClick(View arg0)
					{
						String taskName = taskNameText.getText().toString().trim();
						if(!(taskName.length()==0))
							values.add(taskName);
						adapter.notifyDataSetChanged();
						taskNameText.setText("");
					}
				}
		);
	}
}
